<form  class="layui-form layui-card" onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">

    <div class="layui-card-body">
        <div class="layui-form-item">

            <label class="layui-form-label">管理员验证码</label>

            <div class="layui-input-block">
                <input maxlength="6" name="code_verif" required placeholder="请输入短信验证码" class="layui-input">
                <button style="position: absolute;right: 0;top: 0;z-index: 2" id="send-code-button"  data-title="修改手机号码" type="button" class="layui-btn layui-btn-normal">发送验证码</button>
            </div>
        </div>

    <div class="layui-form-item text-center">
        <button class="layui-btn" id="form-submit-verif" type='button'>确 定</button>
        <button data-close type='button'  id="form-close-verif" style="display: none;">关 闭</button>
   <!--      <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button> -->
    </div>

</div>
<input type="hidden" name="C_type" value="{$C_type}">
<input type="hidden" name="id" value="{$vo.id}">
</form>
<script type="text/javascript">
    //$('input[name="Ch_result"]').val(1)
        var seconds = 15;

        $('#form-submit-verif').on('click',function(){
            console.log(1)
            postData = {};
            postData['companyid'] = $('input[name="id"]').val()
            postData['code'] = $('input[name="code_verif"]').val()
            console.log(postData['code']);
            if(!postData['code']){return $.msg.error("请输入验证码")}
            $.post(SCOPE.submit_url, postData, function(result) {
                if (result.code == 200) {
                    // Cuser Cdel
                    $('input[name="Ch_result"]').val("{$C_type}1")
                    var chtype_val =  $('input[name="Ch_result"]').val()
                    console.log(chtype_val)
                if(chtype_val=='Cuser1'){
                      // Cuser Cdel
                  $('.createuid-select').attr('disabled',false)
                  form.render('select');
                }
                if(chtype_val=='Cdel1'){
                      // Cuser Cdel
                    return $.msg.confirm('确定要删除该企业吗？',function(okres){
                        $.post(SCOPE.delcompany_url, {'id':"{$vo.id}"}, function(result) {
                            console.log(result)
                            if(result.code==1){
                                $.msg.success(result.info,3000)
                                //可注释
                                
                                window.location.reload()
                            }else{

                                $.msg.error(result.info)
                            }

                            $('input[name="Ch_result"]').val("0")
                            $.msg.close(okres);
                        })

                    },function(canel){
                            $('input[name="Ch_result"]').val("0")
                            $.msg.close(canel);
                    })
                }
                    $.msg.success(result.info)
                    $('#form-close-verif').click();
                }else{

                }
            })
        })
        //发送验证码
        $("#send-code-button").click(function() {
        if($('#send-code-button').text()!="发送验证码"){return}
        $("input[name='code']").attr('disabled',true)

        postData = {};
        postData['code'] = $('input[name="code"]').val();
        postData['ty'] = $('input[name="C_type"]').val();
        // postData
        console.log(postData);
        // 将获取到的数据post给服务器
        url = SCOPE.send_url;
        $.post(url, postData, function(result) {
            if (result.code == 200) {
                //成功
                var interval_send = setInterval(function(){
                          seconds = seconds-1
                          $('#send-code-button').text(s)
                          if(seconds == 0){
                               $('#send-code-button').text('发送验证码')
                               clearInterval(interval_send);
                            }
                      },1000)

                layer.open({
                    content: result.info,
                    icon: 1,
                    title: '成功提示'
                });
                //return dialog.success(result.info);
            } else if (result.code == 400) {
                $("input[name='code']").attr('disabled',false)
                // 失败
                layer.open({
                    content: result.info,
                    icon: 2,
                    title: '错误提示'
                });
                //return dialog.error(result.info);
            }
        }, "JSON");
    });


        var SCOPE = {
        'send_url' : "{:url('send_code')}",
        'submit_url': "{:url('verif')}",
        'delcompany_url': "{:url('remove')}",
    };
</script>